﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'GetPermisosByUsuarioAndMenu')
	BEGIN
		DROP  Procedure  GetPermisosByUsuarioAndMenu
	END

GO

CREATE Procedure GetPermisosByUsuarioAndMenu

	(
		@idEmplerado int,
		@idMenu int
	)

AS

BEGIN
	SET NOCOUNT ON
	
	SELECT DISTINCT
	P.[Estado],
	P.[IdEmpleado],
	P.[IdFormulario],
	P.[TipoPermiso]
	FROM [Permiso] AS P
	INNER JOIN Formulario AS F ON P.[IdFormulario] = F.[IdFormulario]
	INNER JOIN Menus AS M ON F.IdMenu = M.IdMenu
	WHERE P.[IdEmpleado] = @idEmplerado AND M.[IdMenu] = @idMenu

	SET NOCOUNT OFF
END

GO


GRANT EXEC ON GetPermisosByUsuarioAndMenu TO PUBLIC

GO


